/*
 * @Description:
 * @Author: BOye
 * @Date: 2023-12-06 20:29:18
 * @LastEditTime: 2024-04-08 20:13:26
 * @LastEditors: yehongbo 1394168736@qq.com
 * @Reference:
 */
// npm i @njleonzhang/postcss-px-to-rem -D
// 在项目根目录新建.postcssrc.js配置文件
// 配置完成后，页面内的 px 就会被转换成 rem 了

(function init(screenRatioByDesign = 16 / 9) {
    let docEle = document.documentElement
    function setHtmlFontSize() {
        var screenRatio = docEle.clientWidth / docEle.clientHeight;
        var fontSize = (
            screenRatio > screenRatioByDesign
                ? (screenRatioByDesign / screenRatio)
                : 1
        ) * docEle.clientWidth / 100;
        docEle.style.fontSize = fontSize.toFixed(3) + "px";
        console.log('fontSize', docEle.style.fontSize);
    }
    setHtmlFontSize()
    window.addEventListener('resize', setHtmlFontSize)
})()